

package com.example.administrator.caigou51.recyclerCard.cardView;

import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.administrator.caigou51.R;
import com.example.administrator.caigou51.activity.OrderListActivity;
import com.example.administrator.caigou51.activity.WebHtmlActivity;
import com.example.administrator.caigou51.global.Constant;
import com.example.administrator.caigou51.recyclerCard.basic.CardItemView;
import com.example.administrator.caigou51.recyclerCard.card.OrderDetail1Card;


public class OrderDetail1CardView extends CardItemView<OrderDetail1Card> {
 	private Context mContext;
    public OrderDetail1CardView(Context context) {
        super(context);
        mContext=context;
        // TODO Auto-generated constructor stub
    }

    public OrderDetail1CardView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mContext=context;
        // TODO Auto-generated constructor stub
    }

    public OrderDetail1CardView(Context context,
                                    AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        mContext=context;
        // TODO Auto-generated constructor stub
    }
    private TextView textViewID;
    private TextView textViewState;
    private ImageView textViewWuLiuMore;
    private RelativeLayout relativeLayoutAddress;
    private TextView textViewName;
    private TextView textViewTel;
    private ImageView imageViewLocation;
    private TextView textView_add;
    private View linearLayoutWuLiu;
    @Override
    public void build(final OrderDetail1Card card) {
        // TODO Auto-generated method stub
        super.build(card);
        textViewID = (TextView) findViewById(R.id.textViewID);
        textViewState = (TextView) findViewById(R.id.textViewState);
        textViewWuLiuMore = (ImageView) findViewById(R.id.textViewWuLiuMore);
        relativeLayoutAddress = (RelativeLayout) findViewById(R.id.relativeLayoutAddress);
        textViewName = (TextView) findViewById(R.id.textViewName);
        textViewTel = (TextView) findViewById(R.id.textViewTel);
        imageViewLocation = (ImageView) findViewById(R.id.imageViewLocation);
        textView_add = (TextView) findViewById(R.id.textView_add);
        linearLayoutWuLiu=findViewById(R.id.linearLayoutWuLiu);

        textViewID.setText("订单编号:  "+card.getOrderDetailBean().getOrder_id());

        textViewState.setText(card.getOrderDetailBean().getStatus());
        if (card.getOrderDetailBean().getStatus().equals(OrderListActivity.DFK+""))
        {
            textViewState.setText("等待付款");
            linearLayoutWuLiu.setVisibility(View.GONE);
        }else if (card.getOrderDetailBean().getStatus().equals(OrderListActivity.DFH+""))
        {
            textViewState.setText("正在出货");
            linearLayoutWuLiu.setVisibility(View.GONE);
        }else if (card.getOrderDetailBean().getStatus().equals(OrderListActivity.DSH+""))
        {
            textViewState.setText("已发货");
            linearLayoutWuLiu.setVisibility(View.VISIBLE);
        }else if (card.getOrderDetailBean().getStatus().equals(OrderListActivity.JYWG+""))
        {
            textViewState.setText("已完成");
            linearLayoutWuLiu.setVisibility(View.VISIBLE);
        }else if (card.getOrderDetailBean().getStatus().equals(OrderListActivity.YQX_1+"") || card.getOrderDetailBean().getStatus().equals(OrderListActivity.YQX_2+""))
        {
            textViewState.setText("交易关闭");
            linearLayoutWuLiu.setVisibility(View.GONE);
        }else if (card.getOrderDetailBean().getStatus().equals(OrderListActivity.YQX_1+"") || card.getOrderDetailBean().getStatus().equals(OrderListActivity.YQX_2+""))
        {
            textViewState.setText("交易关闭");
            linearLayoutWuLiu.setVisibility(View.GONE);
        }else if (card.getOrderDetailBean().getStatus().equals(OrderListActivity.HDFK+""))
        {
            textViewState.setText("正在出货");
            linearLayoutWuLiu.setVisibility(View.GONE);
        }else
        {
            textViewState.setText("正在出货");
            linearLayoutWuLiu.setVisibility(View.GONE);
        }
        textViewName.setText(card.getOrderDetailBean().getBuyer_name());
        textViewTel.setText(card.getOrderDetailBean().getBuyer_mobile());
        textView_add.setText(card.getOrderDetailBean().getBuyer_address());

        linearLayoutWuLiu.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent =new Intent(mContext, WebHtmlActivity.class);
                intent.putExtra(WebHtmlActivity.Title,"物流详情");
                intent.putExtra(WebHtmlActivity.WebUrl, Constant.getHtml5UrlFotParameter(Constant.HTML5.Html5_check_order_state,card.getOrderDetailBean().getExpress_type(),card.getOrderDetailBean().getExpress_number()));
                mContext.startActivity(intent);
            }
        });
    }

}
